﻿using Nemerle.Collections;
using Nemerle.Peg;
using Nemerle.Text;
using Nemerle.Utility;

using System;
using System.Collections.Generic;
using System.Linq;

namespace Nemerle2.Compiler
{
  /// <summary>
  /// Represent using directive.
  /// Note: This node can't be Splicable while it take effect on parsing!
  /// </summary>
  [Record]
  public variant PUsing : PAst
  {
    | Open
      {
        Path : LocatedList[PId];  // TODO: hc: turn to PExpr?
      }
    | Alias
      {
        Name : PId;
        Path : LocatedList[PId]; // TODO: hc: turn to PExpr?
      }
    | Error { Msg : Msg; }

    public override ToString() : string
    {
      match (this)
      {
        | Open(path)        => $<#using ..$(path; ".")#>
        | Alias(name, path) => $<#using $name = ..$(path; ".")#>
        | Error(msg)        => msg.ToString()
      }
    }
  }
}